/**
 * Copyright (c) 2012-2014, Yang Yang <cntototo@gmail.com>
 *
 * This software may be distributed under the terms of the New BSD License.
 * See README for more details.
 */

#ifndef LOOP_H
#define LOOP_H

#include "def.h"

typedef void (*wfs_loop_sock_handler)(int sock, void *ctx);

typedef void (*wfs_loop_sig_handler)(int sig, void *ctx);

typedef void (*wfs_loop_timer_handler)(void *ctx);

enum wfs_internal_err wfs_loop_register_read_sock(int sock,
		wfs_loop_sock_handler handler, void *ctx);

enum wfs_internal_err wfs_loop_unregister_read_sock(int sock,
		wfs_loop_sock_handler handler, void *ctx);

enum wfs_internal_err wfs_loop_register_sig(int sig,
		wfs_loop_sig_handler handler, void *ctx);

enum wfs_internal_err wfs_loop_unregister_sig(int sig,
		wfs_loop_sig_handler handler, void *ctx);

enum wfs_internal_err wfs_loop_register_timer(unsigned int sec,
		unsigned int usec, wfs_loop_timer_handler handler, void *ctx);

enum wfs_internal_err wfs_loop_unregister_timer(wfs_loop_timer_handler handler,
		void *ctx);

enum wfs_internal_err wfs_loop_init(void);

enum wfs_internal_err wfs_loop_terminate(void);

void wfs_loop_run(void);

void wfs_loop_deinit(void);

#endif /* LOOP_H */
